﻿using Microsoft.AspNetCore.Mvc;
using Step4.Unit4.Models;
using Step4.Unit4.Services;

namespace Step4.Unit4.Controllers
{
    public class ProductController : Controller
    {
        private readonly IProductService _productService;
        public ProductController(IProductService productService)
        {
            _productService = productService;
        }


        /// <summary>
        /// 查询视图
        /// </summary>
        /// <returns></returns>
        public IActionResult Search()
        {
            return View(_productService.Search());
        }

        public IActionResult Add() 
        { 
           return View();
        }

        /// <summary>
        /// 提交添加
        /// </summary>
        /// <param name="bo"></param>
        /// <returns></returns>
        public IActionResult Submit(ProductCreateBo bo)
        {
            _productService.Add(bo);
            return RedirectToAction("search");
        }
    }
}
